<%--
 *  File:    AreaAllWindow.jsp
 *  @Author: jackyin 
 *  Date:    2011/02/17
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>


<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.AreaAllWindow");  
  String strModuleName = "OGM";    
  String privilegeCode = "all";
  String contextPath = request.getContextPath();

%>



<%
  //get curuserinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");  
  String strCurOrgName = (String)CurUserInfo.get("orgname");
  Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
  if(nCurOrgId == null)
  {
    nCurOrgId = new Integer(-1234567);
  }  
	int grade = -1;
	if(CurUserInfo.get("grade") != null)
 	{
 	  grade = ((Integer)CurUserInfo.get("grade")).intValue();
 	}
%>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title>BusinessAreaPop</title>
<PageFlow:CheckPageFlow pageName="busiareatree"/>
<%
  Vector areas = (Vector)pageContext.getAttribute("areatree");
  Integer nTreeOrgId = new Integer(-1);    
  if(areas == null)
  {
    areas = new Vector();
  }   
  cat.debug("The areas is :" + areas.size() + areas);
  OvalTree initTree = new OvalTree(areas,"areaid","parentareaid","grade");
  initTree.setRecursiveLimit(2000);
  Vector areaTree = (Vector)initTree.getTreeVector(new Integer(-1000),1);  
  cat.debug("The tree's size is :" + areaTree.size());
  cat.debug("The tree is :" + areaTree);
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<SCRIPT language=JavaScript1.2 src="<%=contextPath %>/css/menu.js"></SCRIPT>
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript">
function page_view(id,grade,isbottom,parentid,areaname,areacode)
{
  document.areatreeform.areaid.value = id;
  //document.areatreeform.grade.value = grade; 
  ///if(grade == 1 || grade == 2){
  // alert("请选择三级区域");
  //  return ;
////}
  //document.areatreeform.isbottom.value = isbottom;  
 // document.areatreeform.parentareaid.value = parentid;  
 // document.areatreeform.areacode.value = areacode;   
  if(id == null || id.length == 0 || id == "" || id < 0)
  {
    return;
  }
  opener.setBusinessarea(id,areaname);  
  window.close();
}
</script>
</head>

<body>

<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
  <form name="areatreeform" method="post" action="<%=contextPath %>/Dispatcher">
       <input type="hidden" name="pagename" value="busiareatree">
       <input type="hidden" name="actionname">
       
       <input type="hidden" name="areaid">
       <input type="hidden" name="isbottom">
       <input type="hidden" name="grade">
       <input type="hidden" name="parentareaid">
       <input type="hidden" name="areacode">
       
  <tr> 
    <td valign="top"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" height="86%">
        <tr> 
          <td colspan="-1" class="deepblue-left"><img src="<%=contextPath %>/images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
            <%= label.getLabelName("L_BusinessAreaName") + label.getLabelName("L_Colon") %></td>
        </tr>
        <tr> 
          <td class="spe-td">                         
		  <div id=div2 style="OVERFLOW: auto; WIDTH: 234px; HEIGHT: 465px">
   <%
   if(areaTree.size() != 0)
   {
     int nTreeLevel = 0;
     int nLevelDif = 0;
     int nTopLevel = 0;
     int nEndLevel = 0;
     String strIMG = "TreeAdd.gif";
     for(int i = 0;i < areaTree.size();i++)
     {
       HashMap temp = (HashMap)areaTree.elementAt(i);
       cat.debug("Now the temp is:" + temp);
       nTreeOrgId = (Integer)temp.get("orgid");
       int nNext = ((Integer)temp.get("next")).intValue();
       String strLevelCode = (String)temp.get("levelcode");       
       nTreeLevel = ((Integer)temp.get("grade")).intValue()+ nLevelDif;
       if(((Boolean)temp.get("ismin")).booleanValue())
       {
         strIMG = "TreeSub.gif";
       }
       else
       {
         strIMG = "TreeAdd.gif";
       }
       for(int j = 0;j <= -nNext;j++)
       {
         if(i != 0)
         {
   %>
            </div>                   
           </td>
          </tr>               
         </table>
   <%    
         }
       }
       
       if(((Boolean)temp.get("ismax")).booleanValue())
       {
         nTopLevel = ((Integer)temp.get("grade")).intValue();
         nTreeLevel = 1;
         nLevelDif = ((Integer)temp.get("grade")).intValue() - 1;
   %> 

      <table cellspacing="0" width="100%">     
       <tr> 
        <td class="TreeClass1"><a href="#" <%if(!((Boolean)temp.get("ismin")).booleanValue()){%>onClick="expandIt(areatreeform,'KB<%=JspHelper.filterNull( strLevelCode )%>','<%=contextPath %>/images/<%= strLanguageCode %>/'); return false"<%}%>><img name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" src="<%=contextPath %>/images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" height="11" border="0" ></a><a href="javascript:page_view('<%=JspHelper.filterNull( temp.get("areaid") )%>','<%=JspHelper.filterNull( temp.get("grade") )%>','<%=JspHelper.filterNull( temp.get("isbottom") )%>','<%=JspHelper.filterNull( temp.get("parentareaid") )%>','<%=JspHelper.filterNull( temp.get("areaname"))%>','<%=JspHelper.filterNull( temp.get("areacode"))%>')"><%=JspHelper.filterNull( temp.get("areaname"))%></a> 
         <div class=child<%=JspHelper.filterNull( strLevelCode )%> id=KB<%=JspHelper.filterNull( strLevelCode )%>Child> 
   <%   
       } 
       if(!((Boolean)temp.get("ismax")).booleanValue() && !((Boolean)temp.get("ismin")).booleanValue())
       {
   %>
          <table cellspacing="0" width="100%">     
           <tr> 
            <td class="TreeClass<%=JspHelper.filterNull( nTreeLevel )%>"><a href="#" onClick="expandIt(areatreeform,'KB<%=JspHelper.filterNull( strLevelCode )%>','<%=contextPath %>/images/<%= strLanguageCode %>/'); return false"><img src="<%=contextPath %>/images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" width="11" height="11" name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" border="0"></a><a href="javascript:page_view('<%=JspHelper.filterNull( temp.get("areaid") )%>','<%=JspHelper.filterNull( temp.get("grade") )%>','<%=JspHelper.filterNull( temp.get("isbottom") )%>','<%=JspHelper.filterNull( temp.get("parentareaid") )%>','<%=JspHelper.filterNull( temp.get("areaname"))%>','<%=JspHelper.filterNull( temp.get("areacode"))%>')"><%=JspHelper.filterNull( temp.get("areaname"))%></a>
            <div class=child<%=JspHelper.filterNull( strLevelCode )%> id=KB<%=JspHelper.filterNull( strLevelCode )%>Child> 
   <%
       }
       if(!((Boolean)temp.get("ismax")).booleanValue() && ((Boolean)temp.get("ismin")).booleanValue())
       {
   %>
          <table cellspacing="0" width="100%">     
           <tr> 
            <td class="TreeClass<%=JspHelper.filterNull( nTreeLevel )%>"><a href="#"><img src="<%=contextPath %>/images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" width="11" height="11" name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" border="0"></a><a href="javascript:page_view('<%=JspHelper.filterNull( temp.get("areaid") )%>','<%=JspHelper.filterNull( temp.get("grade") )%>','<%=JspHelper.filterNull( temp.get("isbottom") )%>','<%=JspHelper.filterNull( temp.get("parentareaid") )%>','<%=JspHelper.filterNull( temp.get("areaname"))%>','<%=JspHelper.filterNull( temp.get("areacode"))%>')"><%=JspHelper.filterNull( temp.get("areaname"))%></a>
             <div>  
   <%
       }
       nEndLevel = ((Integer)temp.get("grade")).intValue();
     }     
     //close the tag
     for(int h = 0; h <= nEndLevel - nTopLevel;h++)
     {
   %>
              </div>     
             </td>
            </tr>    
           </table>              
   <%  
     }
   }          
   %>
      </div>
          </td>
        </tr>
        <tr> 
          <td class="td-listrom">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
    </form> 
</table>

    </body>
<script language="JavaScript">  
  var ht = document.body.clientHeight - 100;
  if(ht < 0 )
    ht = 0;
  div2.style.height= ht;
</script>
    <SCRIPT language=JavaScript1.2>initIt(areatreeform,'<%=contextPath %>/images/<%= strLanguageCode %>/');</SCRIPT>    
</html>
     


